/*
 * DuplicateNameException.java
 *
 *  
 */
package org.msb.finance.data;

/**
 * 
 * 
 * @author Marc Boudreau
 * 
 */
public class DuplicateNameException extends Exception {

	/*
	 * 
	 */
	private static final long serialVersionUID = 1;

	/*
	 * 
	 */
	private Class<?> klass;

	/*
	 * 
	 */
	private String name;

	/**
	 * 
	 * @param klass
	 * @param name
	 */
	public DuplicateNameException(Class<?> klass, String name) {
		this(klass, name, null);
	}

	/**
	 * 
	 * @param klass
	 * @param name
	 * @param cause
	 */
	public DuplicateNameException(Class<?> klass, String name, Throwable cause) {
		super(buildExceptionMessage(klass, name), cause);

		this.klass = klass;
		this.name = name;
	}

	/**
	 * 
	 * @return s
	 */
	public Class<?> getObjectClass() {
		return this.klass;
	}

	/**
	 * 
	 * @return s
	 */
	public String getDuplicateName() {
		return this.name;
	}

	/*
	 * Constructs the appropriate exception message based on the provided Class object and the duplicate name. The Class
	 * object is used to lookup the correct user-friendly object type (e.g. 'BankAccount' is translated to 'Bank
	 * Account').
	 */
	private static String buildExceptionMessage(Class<?> klass, String name) {
		return klass.getName() + ":" + name; //$NON-NLS-1$
	}

}
